package echecs.launch;

import echecs.gen.Generateur;
import echecs.vue.BoardVue;
import java.awt.*;
import javax.swing.JApplet;
import javax.swing.JTextField;

public class LaunchEchecs extends JApplet {

    BoardVue brain;
    Button enter = new Button("Enter");
    JTextField fenField = new JTextField("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");

    @Override
    public boolean action(Event evt, Object arg) {
        if (((String) arg).equals("Enter")) {
            brain.enter(fenField.getText());
        }
        return true;
    }

    @Override
    public void init() {
        super.init();
        //initialize AI
        brain = new Generateur(this) ;
        //GUI
        setBackground(Color.darkGray);
        setLayout(new BorderLayout(10, 10));
        add("Center", brain);
        fenField.setSize(200, 30);
        add("East", enter);
        add("South", fenField);
        setSize(400, 400);
    }

//make a border with 10 bixels width
    @Override
    public Insets insets() {
        return new Insets(10, 10, 10, 10);
    }
}
